home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ada
/
c01oop.zip
/
CPPWKBK
/
CPPV3-1.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-25
|
771b
|
45 lines
#define HEADER "C++ Problem 3.1 by Rick Conn using Borland C++"
#include <stdio.h>
class counter {
static int object_count;
public:
counter();
static int get_count(void);
};
int counter::object_count = 0; // init count
counter::counter() { counter::object_count++; }
int counter::get_count(void)
{
return counter::object_count;
}
void main(void)
{
printf("%s\n", HEADER);
counter c1;
printf("The count is %d\n",
c1.get_count());
counter c2;
printf("The count is %d\n",
counter::get_count());
counter c3;
printf("The count is %d\n",
c3.get_count());
counter c4;
printf("The count is %d\n",
c4.get_count());
counter c5;
printf("The count is %d\n",
c5.get_count());
}